﻿@{
    ViewBag.Title = "BookList";
    Layout = "~/Views/Shared/_Layout_User.cshtml";
    ResourceHelper.RegisterCss(this, "user.BookList.css");
}
@model IList<BabyPlan.mvcApp.ViewModel.BookModel>
           
<div class="right_block_title user_right_block grayblock">
    <span class="title margin10 font-size16 black-font">我的书架</span>
</div>
<div class="goods_input_outer user_right_block  whiteblock right-block_content clearfix">
<ul class="bookList">
  @for (int i = 0, c = Model.Count(); i < c; i++)
  {
      var item = Model[i];
    <li class="clearfix font-size14">
        <a href="@Url.Action("BookView", "Babybook", new { id = item.Id })" target="_blank" class="fl img">
        @switch (item.BookCover)
        { 
            case BookCoverType.A:
        <img src="/images/baby_s.jpg" />
                break;
            case BookCoverType.B:
        <img src="/images/young_s.jpg" />
                break;
            case BookCoverType.C:
        <img src="/images/old_s.jpg" />
                break;
        }

        </a>
        <div class="listContent fl gray-font">
        <p class="font-size16"><b>@item.Name</b></p>
        <p class="describe">@item.Introduction</p>
        <div class="font-size12">
          <a class="green-font editright" href="@Url.Action("AddBook", "Babybook", new { id = item.Id })" target="_blank">编辑</a><label>最后编辑：</label><span class="dateTime"> @item.EditeTime</span>
        </div>
        </div>
        <div class="makeButton fl clearfix">
            <a class="button-green  font-size18 fl" href="javascript:void(gotoTaobao(@item.Id));" title="制作纸质书">制作纸质书</a>
            <a title="下载电子书 fl" href="@Url.Action("BookView", "Babybook", new { id = item.Id })" target="_blank"  class="download">电子书</a>
        </div>
        <a href="javascript:void(deletebook(@item.Id));"  class="delete"></a>
    </li>
  }
 @if (Model.Count == 0)
 { 
        <div class="prompt_info clearfix font-size16 gray-font">你的书架是空的，请 &nbsp<a href="@Url.Action("AddBook", "Babybook")" class="add_goods blue-font">点击制作</a> &nbsp。把宝宝的成长印出来！</div>
 }
            
</ul>
</div>

@section Js_InFoot{
    @Content.Script("json2.js", Url)
    @Content.Css("fancybox/jquery.fancybox-1.3.4.css", Url, BabyPlan.mvcApp.Infras.SourceRootEnums.JsLib)  
    @Content.Script("fancybox/jquery.fancybox-1.3.4.js", Url)
    @Content.Script("fancybox.msgbox.js", Url)
    <script type="text/javascript">
        function deletebook(bookid) {
            $.showConfirmMsg("您确定要删除您的成长记录？", function (result) {
                if (result) {
                    $.ajax({
                        type: "POST",
                        url: '@Url.Action("AjaxDeleteBook", "Babybook")',
                        data: { id: bookid }
                    }).done(function (response) {
                        if (response.Error == 0) {
                            window.location = window.location;
                        } else {
                            $.showMsg(response.ExMessage, "error");
                        }
                    });
                }
            });
          
        }
        function gotoTaobao(bookid)
        {
            $.showMsg("正在建设中...", "success");
        }
    </script>
    }